The technology described herein relates to data processing systems, and in particular to methods of and apparatus for detecting when two numbers representing data values in a data processing system are equal to each other or differ from each other by only one.
The Applicants have recognised that it can be useful in data processing systems to be able to determine whether two binary numbers representing particular data values in the data processing system are equal to each other or only differ from each other by one. For example, this may be, as will be discussed further below, particularly useful in the case of fetching texel (texture data element) values for use in texture mapping in graphics processing systems and graphics processors.
Texture mapping is a technique that is used in graphics processing systems for generating colours for sampling positions in a render output (e.g., image to be displayed). In texture mapping, so-called textures or texture data are applied to the surfaces to be drawn. The textures are typically applied by storing an array of texture elements (“texels”), each representing given texture data (such as colour, luminance, and/or light/shadow, etc. values), and then mapping the texels on to the corresponding elements, such as (and, indeed, typically) a set of sampling positions, for the render output in question (e.g. image to be displayed).
Thus a graphics texture will typically be configured as an array of data elements (texture elements (texels)), each having a corresponding set of texture data stored for it. The texture data for a given position within the texture is then determined by sampling the texture at that position (e.g. using a bilinear interpolation process).
To perform this texture sampling (e.g. bilinear interpolation), the texels (the data values of the texels) surrounding the position within the texture for which the texture value is required will be fetched from the storage (memory) where the graphics texture is stored, into a cache associated with the texture mapping process, with the texel values then being fetched from the cache and subjected to the appropriate, e.g. bilinear, interpolation process, to derive the texture data value to be applied to the surface to be drawn. Thus, as part of the texture mapping process, respective sets of texels will be fetched from memory into a cache, from where the texel values will then be fetched for the texture mapping process.
The texture (texel) cache of a graphics processor will typically include a plurality of cache lines, each able to store a plurality of individual texels. A given cache line may store spatially adjacent texels from the texture (such as texels from the same row in the texture, and/or from two or more adjacent rows in the texture).
In a graphics processing system, the texel fetching process may be able to fetch plural texels per cycle into and from the texture cache, but may be also be constrained by a limit on the maximum number of different cache lines that can be looked-up in a given cycle. In order to maximise throughput of the texture mapping process, it would be desirable to be able to fetch as many texels in as many cache lines as possible in a given cycle.
The Applicants have recognised that in order to increase the throughput of the texel fetching process, it would be desirable to be able to identify those texels that are to be fetched that fall within the same cache line (as then those texels can be fetched from/into that same cache line in the same cycle). This will then facilitate increasing (and maximising) the number of texels that can be fetched in a single cycle.
In graphics texture mapping, texels may be fetched, for example, as respective groups of 2×2 texels (so as to be suitable for bilinearly interpolating to provide texture data value for given positions in the texture). Thus in a given fetching cycle, a plurality of such 2×2 texel groups may be desired to be fetched. Such texel groups may overlap with each other, depending upon the positions of the respective texels within each group. If texels within different texel groups to be fetched overlap with each other, then those texels may belong to (be stored in) the same cache line in the texel cache. Thus, if it is possible to identify whether there is any overlap between texels in respective 2×2 texel groups that are to be fetched in a given fetch cycle, that can be used to identify those texels within the texel groups to be fetched that will belong to the same cache line, thereby allowing the number of texels to be fetched in a given fetch cycle to be optimised (by fetching texels for different texel groups that will reside in the same cache lines in the texel cache).
The Applicants have further recognised that in such arrangements, two 2×2 texel groups will overlap, at least in part (such that at least some texels from the different 2×2 groups may belong to the same cache line), if the respective positions (coordinates) of the texel groups in the texture are the same as each other or only differ from each other by exactly one. For example, if the top-left texels of each 2×2 group have the same position in the texture (the same coordinates in the texture) then the two 2×2 texel groups overlap completely. If one of the coordinates (e.g. the x coordinate) of the top-left texel of one of the 2×2 texel groups is one less than that coordinate for the other 2×2 texel group, and the other coordinates (e.g. the y coordinates) are equal, then two of the texels in each group will overlap with each other (and so on, as will be discussed in more detail below).
Thus the Applicants have recognised that one way to determine whether texels to be fetched for a texture mapping process share the same cache line in the texture cache is to compare the positions (coordinates) of texels to be fetched, and to determine whether those coordinates are the same as each other or differ from each other by exactly one (by only one).
Like numerals are used for like features in the drawings where appropriate.